//
//  PayResultView.m
//  Experss
//
//  Created by 嗯，大葱 on 17/8/7.
//  Copyright © 2017年 嗯，大葱. All rights reserved.
//

#import "PayResultView.h"

@implementation PayResultView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5f];
        
    }
    return self;
}
- (void)setPayResultStr:(NSString *)payResultStr {
    _payResultStr = payResultStr;
}

- (void)setImageStr:(NSString *)imageStr {
    _imageStr = imageStr;
}
- (void)setDetailStr:(NSString *)detailStr {
    _detailStr = detailStr;
    [self configureView2];
}

- (void)configureView2 {
    UIView *bgV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kView_Width - 120,  300)];
    bgV.center = self.center;
    bgV.backgroundColor = [UIColor whiteColor];
    bgV.layer.masksToBounds = YES;
    bgV.layer.cornerRadius = 5.0f;
    [self addSubview:bgV];
    
    
    UIImageView *imageV = [[UIImageView alloc] initWithFrame:CGRectMake(CGRectGetWidth(bgV.frame)/2-50, 30, 100, 100)];
    imageV.image = [UIImage imageNamed:_imageStr];
    [bgV addSubview:imageV];
    
    
    
    UILabel *lb = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(imageV.frame)+20, CGRectGetWidth(bgV.frame), 30)];
    lb.textColor = [UIColor blackColor];
    lb.text = _payResultStr;
    lb.font = kFont20;
    lb.textAlignment = NSTextAlignmentCenter;
    [bgV addSubview:lb];
    
    UILabel *lb2 = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(lb.frame)+5, CGRectGetWidth(bgV.frame) , 20)];
    lb2.text = _detailStr;
    lb2.font = kFont14;
    lb2.textAlignment = NSTextAlignmentCenter;
    lb2.textColor = [UIColor lightGrayColor];
     [bgV addSubview:lb2];
    
    
    
    
    UIButton *backBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
    backBtn.frame = CGRectMake(30,CGRectGetMaxY(lb2.frame)+20, CGRectGetWidth(bgV.frame)-60, 50);
    backBtn.layer.masksToBounds = YES;
    backBtn.layer.cornerRadius = 3;
    backBtn.layer.borderColor = KShouYeBg.CGColor;
    backBtn.layer.borderWidth = 1;
    [backBtn setTitle:@"返回" forState:(UIControlStateNormal)];
    [backBtn setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
    [backBtn addTarget:self action:@selector(handleBackBtn:) forControlEvents:(UIControlEventTouchUpInside)];
    [bgV addSubview:backBtn];
}



- (void)handleBackBtn:(UIButton *)sender {
    
    if(self.delegate && [self.delegate respondsToSelector:@selector(payBackAction:)])
    {
        [self.delegate payBackAction:sender];
    }
    
}

@end
